package me.grm.cs.student;

import me.grm.cs.course.ICourse;
import me.grm.cs.database.IDatabase;
import me.grm.cs.database.TextDatabase;
import me.grm.cs.factory.ICourseFactory;
import me.grm.cs.factory.undergradCourseFactory;

import java.util.ArrayList;
import java.util.Scanner;

public class PostgraduateStudent implements IStudent{
    private final ArrayList<ICourse> courses = new ArrayList<>();

    @Override
    public void login() {
        System.out.println("Login as Postgraduate.");
    }

    @Override
    public void listCourse() {
        for(ICourse c : courses) {
            System.out.println(c);
        }
    }

    @Override
    public void selectCourse() {
        IDatabase database = TextDatabase.getInstance();
        database.listCourses();
        System.out.println("Please specify the index of your course");

        Scanner sc = new Scanner(System.in);
        int choice = sc.nextInt();
        ICourseFactory factory = new undergradCourseFactory();
        courses.add(factory.selectCourse(choice));
    }

    @Override
    public void deleteCourse() {
        System.out.println("Are you sure? You are a postgraduate!");
    }
}
